﻿using ITXHWEB.Models;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Web.Mvc;
using WPFExcelReport;
using WPFExcelReport.Helpers;
using ITXHWEB.Infrastructure;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace ITXHWEB.Controllers
{
    public partial class VABFARBENController : ITXController
    {

        [ChildActionOnly]
        public ActionResult MNOVA10(string returnUrl)
        {
            ModelState.Clear();
            ViewBag.IsVAFReady = MABF.IsVAFReady;
            ViewBag.IsVAReady = MABF.IsVAReady;
            ViewBag.IsWFReady = MABF.IsWFReady;
            ViewBag.IsWSReady = MABF.IsWSReady;
            MABF.VAF.VAFKOLL = "SHW  ";
            AUTOCHK();
            ViewBag.ReturnUrl = returnUrl;
            return PartialView(MABF.VAF);
        }
        public void AUTOCHK()
        {
            PM["ARTST"] = MABF.WFART.Substring(0, 1);
            PM["KOLL"] = MABF.VAF.VAFKOLL;
            PM["ART"] = MABF.WFART.Substring(1, 20);
            PM["FARBE"] = MABF.WFART.Substring(23, 10);
            PM["DES"] = MABF.WFART.Substring(1 + 20 + 2 + 10 * 4 + 7, 20);
            MABF.VAF.VAFART= MABF.WFART.Substring(1, 20);
            MABF.VAF.VAFFFARBE = MABF.WFART.Substring(23, 10);           
            MABF.IsVAFReady = VVAF.CHKVAF(PM);
            MABF.IsVAReady = VVAF.CHKVA(PM);
            MABF.IsWFReady = VVAF.CHKWF(PM);
            MABF.IsWSReady = VVAF.CHKWS(PM);
            if (!MABF.IsVAFReady)
            {
                VVAF.AUTOCHK(PM);
                MABF.IsVAReady = true;
                MABF.IsVAFReady = true;
            } 
        }
    }
}
